/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package GUI.FUNCTION.PASSBOOK;

import BUS.Unity;
import DAO.DataAccessObject;
import GUI.MAINMENU.Home;
import GUI.FUNCTION.CUSTOMER.*;
import GUI.Main;
import java.awt.Color;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.JTable;
import javax.swing.SwingUtilities;
import javax.swing.table.DefaultTableModel;
import org.jdesktop.swingx.JXComboBox;

/**
 *
 * @author wonka
 */
public class FunctionAddPassBook extends org.jdesktop.swingx.JXPanel {
    private     org.jdesktop.swingx.JXPanel workPanel;
    //private String[] detailLTK;
    /**
     * Creates new form Home
     */
    Unity unity=new Unity();
    TablePassBook model_passbook=new TablePassBook();
    String sql="select BookID,FullName,IDNumber,TypeName,InterestRate,AccountBalance,OpeningDate from (customer inner join savingbook on customer.customerid=savingbook.customerid) inner join savingtype on savingtype.typeid=savingbook.typeid";
    public FunctionAddPassBook() throws Exception {
        initComponents();
        model_passbook.SetTable(jXTable1);
        model_passbook.SetData(sql);
        unity.load_combobox(cb_KyHan,"savingtype","TypeName");
        /*
        cb_MaLTK.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                    txt_LoaiTietKiem.setText(detailLTK[0]);
                    txt_KyHan.setText(detailLTK[1]);
                    txt_HTTL.setText( detailLTK[2]);
                    txt_LaiSuat.setText(  detailLTK[3]);
                    txt_DonViTien.setText(  detailLTK[4]);
            }
        });
        */
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jXLabel2 = new org.jdesktop.swingx.JXLabel();
        jXLabel1 = new org.jdesktop.swingx.JXLabel();
        jXLabel10 = new org.jdesktop.swingx.JXLabel();
        MaSo = new org.jdesktop.swingx.JXTextField();
        jXLabel12 = new org.jdesktop.swingx.JXLabel();
        LaiSuat = new org.jdesktop.swingx.JXTextField();
        jXLabel4 = new org.jdesktop.swingx.JXLabel();
        NgayMoSo = new org.jdesktop.swingx.JXDatePicker();
        HoTen = new org.jdesktop.swingx.JXTextField();
        CMND = new org.jdesktop.swingx.JXTextField();
        SoTienGui = new org.jdesktop.swingx.JXTextField();
        jXLabel14 = new org.jdesktop.swingx.JXLabel();
        jXLabel8 = new org.jdesktop.swingx.JXLabel();
        jXLabel3 = new org.jdesktop.swingx.JXLabel();
        jXLabel7 = new org.jdesktop.swingx.JXLabel();
        jXDatePicker2 = new org.jdesktop.swingx.JXDatePicker();
        btn_NhapLai = new org.jdesktop.swingx.JXButton();
        btn_Them_Luu = new org.jdesktop.swingx.JXButton();
        btn_Thoat = new org.jdesktop.swingx.JXButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        jXTable1 = new org.jdesktop.swingx.JXTable();
        cb_KyHan = new org.jdesktop.swingx.JXComboBox();

        setBackground(new java.awt.Color(255, 253, 218));
        setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        setAutoscrolls(true);
        setScrollableHeightHint(org.jdesktop.swingx.ScrollableSizeHint.FIT);
        setScrollableWidthHint(org.jdesktop.swingx.ScrollableSizeHint.FIT);
        addAncestorListener(new javax.swing.event.AncestorListener() {
            public void ancestorMoved(javax.swing.event.AncestorEvent evt) {
            }
            public void ancestorAdded(javax.swing.event.AncestorEvent evt) {
                formAncestorAdded(evt);
            }
            public void ancestorRemoved(javax.swing.event.AncestorEvent evt) {
            }
        });

        jXLabel2.setBackground(new java.awt.Color(153, 255, 255));
        jXLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/Medium_AddPassBook.png"))); // NOI18N
        jXLabel2.setText("Mở Sổ");
        jXLabel2.setFont(new java.awt.Font("Segoe UI Semibold", 1, 18)); // NOI18N

        jXLabel1.setText("Mã Sổ");
        jXLabel1.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N

        jXLabel10.setText("Kỳ Hạn: ");
        jXLabel10.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N

        MaSo.setEnabled(false);

        jXLabel12.setText("Lãi Suất");
        jXLabel12.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N

        LaiSuat.setEnabled(false);

        jXLabel4.setText("Ngày Mở Sổ");
        jXLabel4.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N

        HoTen.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                HoTenActionPerformed(evt);
            }
        });

        CMND.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CMNDActionPerformed(evt);
            }
        });

        SoTienGui.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SoTienGuiActionPerformed(evt);
            }
        });

        jXLabel14.setText("Số Tiền Gửi:");
        jXLabel14.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N

        jXLabel8.setText("Số CMND");
        jXLabel8.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N

        jXLabel3.setText("Tên Khách Hàng:");
        jXLabel3.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N

        jXLabel7.setText("Ngày Đến Hạn");
        jXLabel7.setFont(new java.awt.Font("Times New Roman", 0, 14)); // NOI18N

        jXDatePicker2.setEnabled(false);

        btn_NhapLai.setBackground(new java.awt.Color(255, 255, 51));
        btn_NhapLai.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 102, 0)));
        btn_NhapLai.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/Small_Save.png"))); // NOI18N
        btn_NhapLai.setText("Nhập Lại");
        btn_NhapLai.setFocusPainted(false);
        btn_NhapLai.setMaximumSize(new java.awt.Dimension(150, 40));
        btn_NhapLai.setMinimumSize(new java.awt.Dimension(150, 40));
        btn_NhapLai.setPreferredSize(new java.awt.Dimension(130, 40));
        btn_NhapLai.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_NhapLaiActionPerformed(evt);
            }
        });

        btn_Them_Luu.setBackground(new java.awt.Color(255, 255, 51));
        btn_Them_Luu.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 102, 0)));
        btn_Them_Luu.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/Small_Bills.png"))); // NOI18N
        btn_Them_Luu.setText("Thêm Và Lưu");
        btn_Them_Luu.setFocusPainted(false);
        btn_Them_Luu.setMaximumSize(new java.awt.Dimension(150, 40));
        btn_Them_Luu.setMinimumSize(new java.awt.Dimension(150, 40));
        btn_Them_Luu.setPreferredSize(new java.awt.Dimension(130, 40));
        btn_Them_Luu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_Them_LuuActionPerformed(evt);
            }
        });

        btn_Thoat.setBackground(new java.awt.Color(255, 255, 51));
        btn_Thoat.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(255, 102, 0)));
        btn_Thoat.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Image/Small_Close.png"))); // NOI18N
        btn_Thoat.setText("Thoát");
        btn_Thoat.setFocusPainted(false);
        btn_Thoat.setMaximumSize(new java.awt.Dimension(150, 40));
        btn_Thoat.setMinimumSize(new java.awt.Dimension(150, 40));
        btn_Thoat.setPreferredSize(new java.awt.Dimension(130, 40));
        btn_Thoat.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_ThoatActionPerformed(evt);
            }
        });

        jXTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jXTable1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jXTable1MouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(jXTable1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(11, 11, 11)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(16, 16, 16)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jXLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jXLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jXLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jXLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(LaiSuat, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(cb_KyHan, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(MaSo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(NgayMoSo, javax.swing.GroupLayout.DEFAULT_SIZE, 166, Short.MAX_VALUE))
                        .addGap(48, 48, 48)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jXLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jXLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jXLabel14, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jXLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(33, 33, 33)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(CMND, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(SoTienGui, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(HoTen, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jXDatePicker2, javax.swing.GroupLayout.DEFAULT_SIZE, 182, Short.MAX_VALUE))
                        .addGap(72, 72, 72)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(btn_Thoat, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(btn_Them_Luu, javax.swing.GroupLayout.DEFAULT_SIZE, 162, Short.MAX_VALUE)
                            .addComponent(btn_NhapLai, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addGap(662, 662, 662))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jXLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 1043, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap(36, Short.MAX_VALUE)
                .addComponent(jXLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(jXLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(5, 5, 5)
                        .addComponent(MaSo, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jXLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(HoTen, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(btn_NhapLai, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(23, 23, 23)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(5, 5, 5)
                                .addComponent(jXLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jXLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(CMND, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(cb_KyHan, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(30, 30, 30)
                        .addComponent(btn_Them_Luu, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(5, 5, 5)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(5, 5, 5)
                        .addComponent(jXLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(LaiSuat, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jXLabel14, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(SoTienGui, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(13, 13, 13)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jXDatePicker2, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(btn_Thoat, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(6, 6, 6)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jXLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(NgayMoSo, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jXLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addGap(18, 18, 18)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 223, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    private void btn_Them_LuuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_Them_LuuActionPerformed
        // TODO add your handling code here:
        boolean[] flags=new boolean[6];
        String str="";
        if(HoTen.getText().trim().compareTo("")!=0)
        {
           if(CMND.getText().trim().compareTo("")!=0)
           {
               if(SoTienGui.getText().trim().compareTo("")!=0)
               {
                    //kiem tra so tien gui
                    //kiem tra ngay mo so
               }
               else
               {
                   str+="So Tien Gui Khong Duoc De Trong";
               }
           }
           else
           {
               str+="CMND khong duoc de trong";
           }
        }
        else
        {
            str+="Ho Ten Khong Duoc De Trong\n";
        }
    }//GEN-LAST:event_btn_Them_LuuActionPerformed

    private void HoTenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_HoTenActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_HoTenActionPerformed

    private void btn_ThoatActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_ThoatActionPerformed
        // TODO add your handling code here:
        Home child = new Home();
        child.setVisible(true);
        child.setSize( this.getSize());
        this.removeAll();
        this.add(child);
        this.validate();
        this.repaint();
    }//GEN-LAST:event_btn_ThoatActionPerformed

    private void formAncestorAdded(javax.swing.event.AncestorEvent evt) {//GEN-FIRST:event_formAncestorAdded
        // TODO add your handling code here:
        /*
        DataAccessObject dao = new DataAccessObject();
        try {
//            ResultSet res = new DataAccessObject().Select("KHACH_HANG", "MA_KH ");
//            AddItemToComboBox(res,cb_MaKH);
            ResultSet res= new DataAccessObject().Select("LOAITIETKIEM", "MA_LOAITIETKIEM");
           AddItemToComboBox(res,cb_MaLTK);
           res= new DataAccessObject().Select("LOAITIETKIEM, LOAITIEN", "TEN_LOAITIETKIEM, KYHAN, HINHTHUC_TRALAI, LAISUAT, DON_VI_TIEN",
                    "LOAITIETKIEM.MA_LOAITIEN = LOAITIEN.MA_LOAITIEN AND LOAITIETKIEM.MA_LOAITIETKIEM = '"+ cb_MaLTK.getItemAt(0).toString().trim()+"'");
            
             while (res.next()) 
            {
                    detailLTK[0] = res.getObject(1).toString();
                    txt_LoaiTietKiem.setText(detailLTK[0]);
                      detailLTK[1] = res.getObject(2).toString();
                    txt_KyHan.setText(detailLTK[1]);
                      detailLTK[2] = res.getObject(3).toString();
                    txt_HTTL.setText( detailLTK[2]);
                      detailLTK[3] = res.getObject(4).toString();
                    txt_LaiSuat.setText(  detailLTK[3]);
                      detailLTK[4] = res.getObject(5).toString();
                    txt_DonViTien.setText(  detailLTK[4]);
            }
            
        } catch (Exception ex) {
            Logger.getLogger(FunctionAddPassBook.class.getName()).log(Level.SEVERE, null, ex);
        }
        * */
    }//GEN-LAST:event_formAncestorAdded

    private void CMNDActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CMNDActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_CMNDActionPerformed

    private void SoTienGuiActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SoTienGuiActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_SoTienGuiActionPerformed

    private void jXTable1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jXTable1MouseClicked
        // TODO add your handling code here:
        int index=jXTable1.getSelectedRow();
        for(int i=0;i<jXTable1.getColumnCount();i++)
        {
            if(i==0)
            {
                MaSo.setText(jXTable1.getValueAt(index, i)+"");
            }
            if(i==1)
            {
                HoTen.setText(jXTable1.getValueAt(index, i)+"");
            }
            if(i==2)
            {
                CMND.setText(jXTable1.getValueAt(index, i)+"");
            }
            if(i==3)
            {
                //KyHan.setText(jXTable1.getValueAt(index, i)+"");
                cb_KyHan.removeAllItems();
                cb_KyHan.addItem(jXTable1.getValueAt(index, i));
            }
            if(i==4)
            {
                LaiSuat.setText(jXTable1.getValueAt(index, i)+"");
            }
            if(i==5)
            {
                SoTienGui.setText(jXTable1.getValueAt(index, i)+"");
            }
            if(i==6)
            {
                NgayMoSo.setDate((Date) jXTable1.getValueAt(index, i));
            }
        }
    }//GEN-LAST:event_jXTable1MouseClicked

    private void btn_NhapLaiActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_NhapLaiActionPerformed
        // TODO add your handling code here:
        try {
            cb_KyHan.removeAllItems();
            unity.load_combobox(cb_KyHan, "SavingType", "TypeName");
            MaSo.setText("");
            HoTen.setText("");
            CMND.setText("");
            LaiSuat.setText("");
            SoTienGui.setText("");
            NgayMoSo.setDate(new Date());
        } catch (Exception e) {
        }
    }//GEN-LAST:event_btn_NhapLaiActionPerformed
public void AddItemToComboBox(ResultSet rs, final JXComboBox cmb){
    try {
    final List<String> allItems = new ArrayList<String>();
    while(rs.next()) {
        String result = rs.getString(1);
        if (result != null) {
            result = result.trim();
        }
        allItems.add(result);
    }
    SwingUtilities.invokeLater(new Runnable() {

        @Override
        public void run() {
        for (String item: allItems) {
                cmb.addItem(item);
            }
        }
    });
     }catch (Exception ex) {
        ex.printStackTrace();
    } finally {
        if (rs != null) {
            try {
                rs.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
    }}
}
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private org.jdesktop.swingx.JXTextField CMND;
    private org.jdesktop.swingx.JXTextField HoTen;
    private org.jdesktop.swingx.JXTextField LaiSuat;
    private org.jdesktop.swingx.JXTextField MaSo;
    private org.jdesktop.swingx.JXDatePicker NgayMoSo;
    private org.jdesktop.swingx.JXTextField SoTienGui;
    private org.jdesktop.swingx.JXButton btn_NhapLai;
    private org.jdesktop.swingx.JXButton btn_Them_Luu;
    private org.jdesktop.swingx.JXButton btn_Thoat;
    private org.jdesktop.swingx.JXComboBox cb_KyHan;
    private javax.swing.JScrollPane jScrollPane1;
    private org.jdesktop.swingx.JXDatePicker jXDatePicker2;
    private org.jdesktop.swingx.JXLabel jXLabel1;
    private org.jdesktop.swingx.JXLabel jXLabel10;
    private org.jdesktop.swingx.JXLabel jXLabel12;
    private org.jdesktop.swingx.JXLabel jXLabel14;
    private org.jdesktop.swingx.JXLabel jXLabel2;
    private org.jdesktop.swingx.JXLabel jXLabel3;
    private org.jdesktop.swingx.JXLabel jXLabel4;
    private org.jdesktop.swingx.JXLabel jXLabel7;
    private org.jdesktop.swingx.JXLabel jXLabel8;
    private org.jdesktop.swingx.JXTable jXTable1;
    // End of variables declaration//GEN-END:variables
}
